package com.handle.common.core.constants;

import com.handle.common.core.utils.StringUtils;

public class ConstantEnums {

    public enum DataScope{
        DATA_SCOPE_ALL("1","全部数据权限"),
        DATA_SCOPE_CUSTOM("2", "自定数据权限"),
        DATA_SCOPE_DEPT("3", "部门数据权限"),
        DATA_SCOPE_DEPT_AND_CHILD("4", "部门及以下数据权限"),
        DATA_SCOPE_SELF("5","仅本人数据权限");
        private final String code;
        private final String value;

        DataScope(String code, String value) {
            this.code = code;
            this.value = value;
        }

        public String getCode() {
            return code;
        }

        public String getValue() {
            return value;
        }

        public static DataScope getTypeByValue(String value){
            if (StringUtils.isNull(value)){
                return null;
            }
            for (DataScope enums : DataScope.values()) {
                if (enums.getCode().equals(value)) {
                    return enums;
                }
            }
            return null;
        }
    }

    public enum MenuStatus{
        VISIBLE(1, "显示"),
        CONCEAL(0,"隐藏");

        private final int code;
        private final String value;

        MenuStatus(int code, String value) {
            this.code = code;
            this.value = value;
        }

        public Integer getCode() {
            return code;
        }

        public String getValue() {
            return value;
        }
    }

    public enum MenuType{
        DIRECTORY("M", "目录"),
        MENU("C","菜单"),
        METHODS("F","方法");

        private final String code;
        private final String value;

        MenuType(String code, String value) {
            this.code = code;
            this.value = value;
        }

        public String getCode() {
            return code;
        }

        public String getValue() {
            return value;
        }

        public static MenuType getTypeByValue(String value){
            if (StringUtils.isNull(value)){
                return null;
            }
            for (MenuType enums : MenuType.values()) {
                if (enums.getCode().equals(value)) {
                    return enums;
                }
            }
            return null;
        }
    }
}
